package comp6231.project.common;

import java.io.*;
import java.math.BigInteger;

public class Message implements Serializable {

	public static final String REQUEST_BUY 			= "BUY";
	public static final String REQUEST_RETURN 		= "RETURN";
	public static final String REQUEST_CHECKSTOCK	= "CHECKSTOCK";
	public static final String REQUEST_EXCHANGE		= "EXCHANGE";
	public static final String REQUEST_NEGACK		= "NEGACK";
	public static final String REQUEST_GETREPLSTATE = "GETREPLSTATE";	// Get a replica state
	public static final String REQUEST_REPLREPLICA	= "REPLREPLICA";	// Replace a replica
	public static final String REQUEST_REPL_ACK		= "REPL_ACK";		// Acknowledge replica replacement is done
	
	public BigInteger sequenceNum;
	public String request;
	public String customerID;
	public String itemID;
	public int numItems;
	public String exchangeItemID;
	public int numExchangeItems;
	
	public String replicaID;		// indicate from which Replica result is from 
	public int result;				// result from Replica

	public static void main(String[] args) {
		Message m = new Message();
		m.sequenceNum = BigInteger.valueOf(1);
		m.customerID = "000001";
		m.exchangeItemID = "0001";
		m.itemID = "0002";
		m.request = Message.REQUEST_CHECKSTOCK;
		m.numItems = 10;
		m.numExchangeItems = 10;
		byte[] buf = Utils.toBytes(m);
		Message m2 = (Message)Utils.fromBytes(buf);
		int a = 0;
	}
}
